#include <iostream>
#include <vector>
#include <string.h>

using namespace std;

// before C++11
int old_for_cycle() {
    char arc[] = "http://c.biancheng.net/cplus/11/";
    int i;
    //for循环遍历普通数组
    for (i = 0; i < strlen(arc); i++) {
        cout << arc[i];
    }
    cout << endl;

    vector<char>myvector(arc,arc+23);
    vector<char>::iterator iter;
    //for循环遍历 vector 容器
    for (iter = myvector.begin(); iter != myvector.end(); ++iter) {
        cout << *iter;
    }
    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
using namespace std;

// C++11
int new_for_cycle() {
    cout << "New for cycle with C++11" << endl;
    char arc[] = "abcde";

    for (char ch : arc) {
        cout << ch;
    }
    cout << endl;

    vector<char>myvector(arc, arc + 5);
    //for循环遍历并修改容器中各个字符的值
    for (auto &ch : myvector) {
        cout << ch;
        ch++;
    }
    cout << endl;

    //for循环遍历输出容器中各个字符
    for (auto ch : myvector) {
        cout << ch;
    }
    cout << endl;
    return 0;
}

int main() {
    // old_for_cycle();

    new_for_cycle();
}